package com.szzg10.mina2.chapter7;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

public class Chapter7Handler extends IoHandlerAdapter {

	@Override
	public void sessionCreated(IoSession session) throws Exception {
		System.out.println("Session Created!!!");
	}
	
	@Override
	public void sessionOpened(IoSession session) throws Exception {
		System.out.println("Session Opened!!!");
	}
	
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		System.out.println("Session Closed!!!");
	}
	
	@Override
	public void sessionIdle(IoSession session, IdleStatus status)
			throws Exception {
		System.out.println("Session Idle!!!");
	}
	
	@Override
	public void exceptionCaught(IoSession session, Throwable cause)
			throws Exception {
		System.out.println("Exception Caught!!!");
	}
	
	@Override
	public void messageReceived(IoSession session, Object message)
			throws Exception {
		
		System.out.println("----------Message Received----------");
		System.out.println(message.toString());
		System.out.println("----------Message Received----------");
		
		session.write("Hello!!!");
	}
	
	@Override
	public void messageSent(IoSession session, Object message) throws Exception {
		
		System.out.println("----------Message Sent----------");
		System.out.println(message.toString());
		System.out.println("----------Message Sent----------");
	}
	
	
	
}
